/**
 * @file        system_config.c
 * @author      Weyne
 * @version     V01
 * @date        2016.09.11
 * @brief       系统配置部分
 * @note				
 * @attention   COYPRIGHT WEYNE
 */
 #include "system_config.h"
 
 
 IapFun Jump2App;
 
 const uint32_t __attribute__((at(BOOT_KEY_ADDRESS))) KeyStore[] = 
{
0x5A2F5D85,1158026309,2646107200,268898138,3366283622,1034319515,2715183288,1681262590,1639004088,2241270322,2756998392,2822637122,1273695416,3133304016,3247481226,3301571560,
2012120725,2020293459,2255264068,2895043959,2309484305,726774587,1696756870,3121493469,3088839557,2338133618,448976500,918347704,124477103,3792355168,1832744806,1754545281,
2070242881,405661271,2830358917,3542317216,1285801524,284262163,1717809200,96644921,4130955532,3912661373,3220673233,341679386,645765114,3535438667,3304772092,2526045492,
2943890526,3293985441,937476140,3487746115,1352057963,3095171427,31474566,666310907,1511172260,1266823259,1227700346,3874678892,1242053104,2480600408,3656474040,467270109,
4144811785,875538071,3342398867,2966460461,1532793537,2364077418,395324347,1249616680,3520909816,3738032945,1912056013,3793349469,3391911421,1340251551,1626501181,3680140914,
1944024372,3151272179,1535452380,1398373311,465125339,2498907560,807319693,3370024724,1748453769,3069779122,2150871669,2203922752,1017798197,2614875408,2115605433,4079410849,
3269532177,1633224104,2953500488,3279489099,3525843078,1520704770,3579902622,2852034677,3307498714,4243539001,253352151,760829353,2370625736,947012605,1977942518,2264116854,
2113222148,1338797825,288509234,972809843,2396424576,1286612796,1049130673,1114604033,2732631360,4219391441,3468832827,637190572,1174148154,3579225515,2927072004,151341656,
1818500478,4232954496,2382026995,977970420,3868371405,3702121445,3312493540,571153788,3492716918,3788006259,962885917,1623625540,97324683,3256142111,1235751599,3357039616,
1111702018,1984341747,2631406189,379835911,342208496,1116490826,282049490,1603321940,2600001574,2528298268,2872042946,1706693830,2926176873,32305893,3875817795,752089791,
3544761267,3412464341,319611551,4272688338,1877408443,747068895,1874935937,741517549,714401717,192724374,3074590456,3218442706,4088658555,142285172,698336613,1056757376,
3915507223,3551775016,2575462679,3036925584,484943897,588181568,2718082007,757333704,3477055289,3570098706,238821004,206819719,2953635132,4164264490,4257782985,293464739,
2813245328,3101120052,2215700169,4158097370,3785662614,748524699,1093071948,905944794,969355066,646160458,3628617176,2342329070,3795446664,3973661831,414395027,2876727998,
1735763986,3363557788,3495675586,2682742845,3292253811,1910884527,2915751376,2893679115,594427527,1937413509,1112332222,3322190118,3960352896,1750779398,1702991485,2316320221,
3708580584,259997286,104664536,2493799632,2623388064,462371898,2027464341,874385299,1861442,3774983153,1321605128,1622002298,3019886198,1902637075,476383651,683585304,
3642000097,1928958908,2503290514,2638492760,3352523505,2093100696,1602214271,778225822,3438160755,3395132922,766491234,1259041778,1876243477,3050281816,4178573225,2858740135,
2785436434,370201609,1219557650,1878108195,1456017744,3234672698,3254681907,1920666360,3463829159,3151326770,2476409916,2591246370,1386066745,1154621979,131781620,164801520,
570741188,2039183423,2359728712,905370774,443686729,704147995,3480867805,952423241,1252182768,552788538,222472281,631422001,2535973004,3786793992,1435274540,3552433895,
1900777416,1128876817,3005144429,260397933,200158558,553275157,1440702736,668411770,182018053,1942458352,968370640,3481692221,794706865,1071716594,3562116689,145420587,
2584938184,110887254,551630451,302718566,1984970321,487234580,3111318706,764704134,2512825466,1190827462,3582029204,616562037,590765853,687285317,91018870,3644664816,
1060622238,3799322987,620780212,2165776588,837037414,2239713021,2727109801,330563900,1137952597,3292653303,1351972527,3124718499,7821238,2228438882,2311777991,2654871022,
3184986354,3951472503,481686485,3587754012,1486290765,3413685822,4287831863,666315352,2446955318,797311003,697359405,783889303,588730484,853114530,342988692,2644193000,
2282870083,1831802942,262390468,485003005,238793733,4039149481,924408753,448828126,1827645950,3973874348,3797083623,3050734275,3417295937,1512468935,242946971,199795565,
3287587367,38522895,2249295188,1456069933,2926984595,1267356324,1830051031,753232956,2703630198,3121699405,4174480434,1608160421,152839885,635411211,255677768,3340089398,
103338861,3894689195,1705312062,239742628,1683378702,3102378881,3391759047,1516953216,2117251168,1992079152,2313116172,2764295215,1902265721,2458090309,2424751151,3043364387,
223053062,2082759881,802577143,3564319809,3529997254,1662102779,3735020494,1545754503,1231444178,3110716339,253487579,1142980005,1032199046,748562661,573894979,2206838993,
22462343,1505376858,821118477,123509599,2032086330,1053243769,219942003,3093099264,3927029772,877056257,3671029254,3249699137,3362803685,3863111553,2597648348,3389683372,
2622150611,3531860585,2153186376,4284087134,3111839741,3287425525,2548288195,4072048027,2062165549,2163442925,433121729,1287025595,1238025613,1546276535,4106406282,838846803,
1262994156,3519689722,2439306409,3771191639,1868140322,900137155,4069428788,2626137743,869193793,3654860356,3921140003,2546899561,1424692721,2503605539,1717773983,1692062300,
1782908259,994234872,2015824464,2743075661,3055809681,4289719431,4249121038,1002657699,1344392025,1429923960,1449103247,4041699527,3472399333,2055135614,290425765,2732561692,
2186880811,3352477943,3820653445,1474419657,721046187,2405844735,3178680308,1071233406,3189516095,2058058946,4092947298,2517553302,2412820653,1411078175,645146424,718548428,
2487761644,1108866206,2251051412,3134938843,1728998792,963857580,1270030282,898361355,1430677946,3458551178,2810517849,570454615,388503551,1872745606,3123322644,1655213689,
};


	
 /**
  * @brief  跳转到APP程序
  * @param  None
  * @retval None
  */
void JumpToApp(void)
{
	if(((*(vu32*)APP_BASE_ADDRESS)&0x2FFE0000) == 0x20000000)
	{
		SCB->VTOR = APP_BASE_ADDRESS;
		Jump2App = (IapFun)*(vu32*)(APP_BASE_ADDRESS+4);
		MSR_MSP(*(vu32*)APP_BASE_ADDRESS);
		Jump2App();
	}
}

 
 //THUMB指令不支持汇编内联
//采用如下方法实现执行汇编指令WFI  
__asm void WFI_SET(void)
{
	WFI;		  
}
//关闭所有中断(但是不包括fault和NMI中断)
__asm void INTX_DISABLE(void)
{
	CPSID   I
	BX      LR	  
}
//开启所有中断
__asm void INTX_ENABLE(void)
{
	CPSIE   I
	BX      LR  
}
//设置栈顶地址
//addr:栈顶地址
__asm void MSR_MSP(uint32_t addr) 
{
	MSR MSP, r0 			//set Main Stack value
	BX r14
}

/************************ (C) COPYRIGHT  WEYNE *****END OF FILE****/

